<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets the trace of the executing generator</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectiongenerator.getthis.html">« ReflectionGenerator::getThis</a></li>
      <li style="float: right;"><a href="class.reflectionfiber.html">ReflectionFiber »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectiongenerator.html">ReflectionGenerator</a></li>
    <li>Gets the trace of the executing generator</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectiongenerator.gettrace" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionGenerator::getTrace</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionGenerator::getTrace</span> &mdash; <span class="dc-title">Gets the trace of the executing generator</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectiongenerator.gettrace-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionGenerator::getTrace</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = <strong><code>DEBUG_BACKTRACE_PROVIDE_OBJECT</code></strong></span></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Get the trace of the currently executing generator.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectiongenerator.gettrace-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       The value of <code class="parameter">options</code> can be any of
       the following flags.
      </p>
      <p class="para">
       <table class="doctable table">
        <caption><strong>Available options</strong></caption>
        
         <thead>
          <tr>
           <th>Option</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>
            <strong><code>DEBUG_BACKTRACE_PROVIDE_OBJECT</code></strong>
           </td>
           <td>
            Default.
           </td>
          </tr>

          <tr>
           <td>
            <strong><code>DEBUG_BACKTRACE_IGNORE_ARGS</code></strong>
           </td>
           <td>
            Don&#039;t include the argument information for functions in the stack
            trace.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectiongenerator.gettrace-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the trace of the currently executing generator.
  </p>
 </div>


  <div class="refsect1 examples" id="refsect1-reflectiongenerator.gettrace-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5265">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionGenerator::getTrace()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;yield&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />}<br /><br />function&nbsp;</span><span style="color: #0000BB">bar</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;yield&nbsp;from&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">();<br />}<br /><br />function&nbsp;</span><span style="color: #0000BB">baz</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;yield&nbsp;from&nbsp;</span><span style="color: #0000BB">bar</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">$gen&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">baz</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$gen</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">();&nbsp;</span><span style="color: #FF8000">//&nbsp;start&nbsp;the&nbsp;generator<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">((new&nbsp;</span><span style="color: #0000BB">ReflectionGenerator</span><span style="color: #007700">(</span><span style="color: #0000BB">$gen</span><span style="color: #007700">))-&gt;</span><span style="color: #0000BB">getTrace</span><span style="color: #007700">());</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(2) {
  [0]=&gt;
  array(4) {
    [&quot;file&quot;]=&gt;
    string(18) &quot;example.php&quot;
    [&quot;line&quot;]=&gt;
    int(8)
    [&quot;function&quot;]=&gt;
    string(3) &quot;foo&quot;
    [&quot;args&quot;]=&gt;
    array(0) {
    }
  }
  [1]=&gt;
  array(4) {
    [&quot;file&quot;]=&gt;
    string(18) &quot;example.php&quot;
    [&quot;line&quot;]=&gt;
    int(12)
    [&quot;function&quot;]=&gt;
    string(3) &quot;bar&quot;
    [&quot;args&quot;]=&gt;
    array(0) {
    }
  }
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectiongenerator.gettrace-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectiongenerator.getfunction.html" class="methodname" rel="rdfs-seeAlso">ReflectionGenerator::getFunction()</a> - Gets the function name of the generator</span></li>
    <li class="member"><span class="methodname"><a href="reflectiongenerator.getthis.html" class="methodname" rel="rdfs-seeAlso">ReflectionGenerator::getThis()</a> - Gets the $this value of the generator</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>